//
//  RJCheckSendModel.m
//  AirQuality
//
//  Created by Mac on 15/11/19.
//  Copyright © 2015年 Po. All rights reserved.
//

#import "RJCheckSendModel.h"

@interface RJCheckSendModel ()

@property (strong, nonatomic) NSArray * stationCode;            //站点号

@end

@implementation RJCheckSendModel


- (void)allStationCodedata{
    _allStationdata = [NSMutableDictionary dictionary];
    for (NSInteger i = 0; i < self.stationCode.count; i ++) {
        NSString * stationString = _stationCode[i];
      __block  NSInteger markCount = 0;
        [RJNetWork myNetRequestWithAddress:[NetURL defaultURL].stationData data:@{@"stationcode":stationString,@"timepoint":[RJTools getTimeWithFormat:@"yyyy-MM-dd" time:YesterdayDate]} completeBlock:^(id responseObject) {
            NSArray * arr = responseObject[@"data"];
            NSMutableArray * probleamKeys = [NSMutableArray arrayWithArray:@[@"pm2_5",@"pm10",@"o3",@"so2",@"no2",@"co"]];
            for (NSDictionary * dic in arr) {
                for (NSUInteger j = 0; j < probleamKeys.count; j ++) {
                    NSString * markKey = [NSString stringWithFormat:@"%@_mark",probleamKeys[j]];
                    NSString * mark = dic[markKey];
                    if (![mark  isEqual: @""]) {
                        markCount ++;
                    }
                }
                
            }
            [_allStationdata setObject:[NSString stringWithFormat:@"%ld",markCount] forKey:stationString];
            self.getAllDataBlock(_allStationdata);
            [[NSNotificationCenter defaultCenter] postNotificationName:@"SendAllData" object:_allStationdata];;
        }failBlack:^(id response) {
            
        }];
    }
    
}

- (void)getAllstationCode:(NSArray *) stationCode{

    _stationCode = [NSArray arrayWithArray:stationCode];
    [self allStationCodedata];
}

@end
